﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Xml.Linq;
using System.IO;
using System.Globalization;


namespace MMITCore.Logging
{
    public class SynkronException : Exception
    {
        #region Member Variables + Properties
        private Int32 m_exceptionID;
        private string m_sourceDetail;

        /// <summary>
        /// The I2S ExceptionID for this exception
        /// </summary>
        public Int32 ID
        {
            get { return this.m_exceptionID; }
        }

        /// <summary>
        /// The Assembly, Class and Function Detail
        /// </summary>
        public String SourceDetail
        {
            get { return this.m_sourceDetail; }
        }
        #endregion

        public SynkronException(object data,
                            Int32 exceptionID,
                            string functionName,
                            string message)
            : base(message)
        {
            this.m_exceptionID = exceptionID;
            this.m_sourceDetail = data.ToString() + ": " + functionName;
        }

        public SynkronException(object data,
                            Int32 exceptionID,
                            string functionName,
                            string message,
                            Exception inner)
            : base(message, inner)
        {
            this.m_exceptionID = exceptionID;
            this.m_sourceDetail = data.ToString() + ": " + functionName;
        }

        #region System.Serializable Functions
        protected SynkronException(System.Runtime.Serialization.SerializationInfo info,
                                   System.Runtime.Serialization.StreamingContext context)
            : base(info, context)
        {
            if (info != null)
            {
                this.m_exceptionID = info.GetInt32("ExceptionID");
                this.m_sourceDetail = info.GetString("Source");
            }
        }

        public override void GetObjectData(SerializationInfo info,
                                           StreamingContext context)
        {
            base.GetObjectData(info, context);

            if (info != null)
            {
                info.AddValue("ExceptionID", this.m_exceptionID);
                info.AddValue("Source", this.m_sourceDetail);
            }
        }
        #endregion

    }
}